home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / System / popup-menu-cdef ƒ / pup.ReadMe < prev    next >
Encoding:
Text File  |  1990-04-15  |  5.5 KB  |  125 lines  |  [TEXT/KAHL]

  1. /*
  2.  *  pup.ReadMe
  3.  *
  4.  *  Copyright © 1990, Michael S. Engber
  5.  */
  6.  
  7. This code was written with THINK C 4.0. Permission is granted to use and
  8. redistribute the CDEF and/or the source. Send me any bugs, comments,
  9. suggestions.
  10.  
  11.   Michael S. Engber
  12.   2642 Prairie Ave
  13.   Evanston, IL  60201
  14.   
  15.   INTERNET: engber@ils.nwu.edu
  16.   CompuServe: 70007,3505
  17.   
  18.  
  19. These files provide three things. The first two being of general interest,
  20. the last is THINK C specific.
  21.  
  22.   1) a pop-up menu CDEF which you can use. Use ResEdit and Copy it out
  23.   of pupCDEF.rsrc. DON'T use the CDEF in pup.π.rsrc. It's a fake CDEF for use
  24.   in debugging CDEFs (see #3 below)
  25.      
  26.     A pop-up menu CDEF is provided with the communications toolkit and
  27.     its supposed to be part of system 7.0 so this code is for people who:
  28.     - don't have the com toolkit and want pop-menu's now
  29.     - use the com toolkit pup, but need to give out their code.
  30.       (the toolkit license doesn't give permision to re-distribute the CDEF)
  31.        
  32.     I tried to make this as isomorphic to the system 7.0 CDEF as possible so   
  33.     minimal changes to your code will be required to switch over. I don't own  
  34.     the com toolkit, so I worked from info I got from some of the Apple 
  35.     people on comp.sys.mac.programmer. I believe the main difference will be 
  36.     that I've taken contrlRfCon away from you and use it to store botRight  
  37.     of the pop-up title box. The Apple version plays some games with
  38.     extending the size of the control record to hold this extra info.
  39.  
  40.   2) an example of CDEF source in C.
  41.      
  42.   3) an example of how to make a single THINK C project that both defines
  43.   and tests a CDEF. Normally, you'd have to have a CDEF project that
  44.   creates a CDEF resource and a test project that uses that resource, and
  45.   constantly switch between the two. MPW users don't have to hassle with
  46.   this. If you want to play around with my code create a project named pup.π
  47.   which contains MacTraps, pup.c & main.c.
  48.      
  49.     This project won't actually create a CDEF resource. To make the CDEF:
  50.     - create a new project that includes a copy of pup.c (leave out main.c)
  51.     - change CDEFmain() to main()
  52.     - set the project type file type to CDEF
  53.     - build
  54.   Note: the compiled CDEF is in pupCDEF.rsrc so you don't have mess with
  55.   re-compiling my code it unless you want to customize it.
  56.  
  57.  
  58.  
  59. Using a Pup:
  60.  
  61.   The contrlRect is divided into two parts, the title box and the pop-up box. The
  62.   width of the title box is specified by the value of contrlMax when the control
  63.   is created. The pop-up box gets the rest of the control rectangle. The pop-up
  64.   title is drawn right justified and the pop-up box is drawn left justified. This
  65.   makes it easy to line up rows of pup's as per IM V p. 25. When the currently
  66.   selected item's title is too wide to fit in the pop-up box then it is truncated
  67.   and '…' is appended to it. One difference between my pup's and the other
  68.   implementations I've seen is that my pop-up box width shrinks/grows to snugly
  69.   fit the currently selected item (it looks nicer - have I offended the ATP?).
  70.     
  71.   The menu handle is stored in contrlData. You can freely manipulate the
  72.   menu handle to add/delete/check items, etc.
  73.     
  74.   Use SetCtlValue()/GetCtlValue() to get/set the item number of the currently
  75.   selected pup menu item.
  76.   
  77.   contrlRfCon is used to store botRight of the title box - DON'T CHANGE IT
  78.  
  79.  
  80. Creating a Pup:
  81.  
  82.   If contrlMin is non-zero it is assumed to be the resource id of a 'MENU'
  83.   resource to use as the pup. If cntrlMin is zero then Unique1ID() is used to
  84.   create a menu id. When there is no 'MENU' rsrc to use (i.e. cntrlMin is an
  85.   invalid id or zero), a new empty menu is created with contrlTitle as the title
  86.   and contrlMin as its id. In either case, after creating the menu cntrMin gets
  87.   reset to 1 so the control will work properly.
  88.     
  89.   contrlMax determines the width of the pop-up title box. After storing this
  90.   info away contrlMax is then reset to 9999 for simplicity. You could try and
  91.   keep it set to the number of items in the menu, but then whenever you add
  92.   or delete menu items you have remember to update it. Since there is know way
  93.   the user can force the control out of range I didn't see any reason to
  94.   complicate things.
  95.     
  96.   If contrlRfCon is non-zero, it is interpreted as a ResType and passed to
  97.   AddResMenu() to initialize the menu. It is then reset to hold botRight of the
  98.   pop-up title box. DO NOT CHANGE contrlRfCon once the control is created (sorry)
  99.     
  100.   contrlValue determines the initially selected item.
  101.   
  102.  
  103. Two Minor Bugs (if you can fix - please pipe up):
  104.     
  105.   1)The menu manager draws the menu in the popped state. So it should make use of
  106.   any color specifications in your menu resource. But, my lazy code makes no
  107.   attempt to draw in color.
  108.     
  109.   The proper way to fix this not write more code, but less. If you use the
  110.   menu definition procedure to draw the current item instead of drawing it by
  111.   hand, you can be sure that it's drawn properly. How? By sending it an
  112.   appropriate message. "What message is that?" you ask. Well, I hear that the
  113.   standard MDEF is or will support such a message and it might even get documented
  114.   "if we have time."
  115.     
  116.   2) When you put a pup in a dialog box it's item number never get's
  117.   returned by ModalDialog(). Why? I don't know. As far as I can tell I've
  118.   done everything right.
  119.  
  120.  
  121. What's the term pup?
  122.  
  123.   In the Oscar docs the author made reference to a new vastly improved user
  124. interface with all the "ugly pup menus" removed. It may have been a typo on his
  125. part, but I kinda like the name pup.